home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / pcl / src-16f.lha / compiler / sparc / subprim.lisp < prev    next >
Encoding:
Text File  |  1991-11-06  |  1.7 KB  |  61 lines

  1. ;;; -*- Package: SPARC -*-
  2. ;;;
  3. ;;; **********************************************************************
  4. ;;; This code was written as part of the Spice Lisp project at
  5. ;;; Carnegie-Mellon University, and has been placed in the public domain.
  6. ;;; If you want to use this code or any part of Spice Lisp, please contact
  7. ;;; Scott Fahlman (FAHLMAN@CMUC). 
  8. ;;; **********************************************************************
  9. ;;;
  10. ;;; $Header: subprim.lisp,v 1.1 90/11/30 17:05:04 wlott Exp $
  11. ;;;
  12. ;;;    Linkage information for standard static functions, and random vops.
  13. ;;;
  14. ;;; Written by William Lott.
  15. ;;; 
  16. (in-package "SPARC")
  17.  
  18.  
  19.  
  20. ;;;; Length
  21.  
  22. (define-vop (length/list)
  23.   (:translate length)
  24.   (:args (object :scs (descriptor-reg) :target ptr))
  25.   (:arg-types list)
  26.   (:temporary (:scs (descriptor-reg) :from (:argument 0)) ptr)
  27.   (:temporary (:scs (non-descriptor-reg) :type random) temp)
  28.   (:temporary (:scs (any-reg) :type fixnum :to (:result 0) :target result)
  29.           count)
  30.   (:results (result :scs (any-reg descriptor-reg)))
  31.   (:policy :fast-safe)
  32.   (:vop-var vop)
  33.   (:save-p :compute-only)
  34.   (:generator 50
  35.     (let ((done (gen-label))
  36.       (loop (gen-label))
  37.       (not-list (generate-cerror-code vop object-not-list-error object)))
  38.       (move ptr object)
  39.       (move count zero-tn)
  40.  
  41.       (emit-label loop)
  42.  
  43.       (inst cmp ptr null-tn)
  44.       (inst b :eq done)
  45.       (inst nop)
  46.  
  47.       (test-type ptr temp not-list t vm:list-pointer-type)
  48.  
  49.       (loadw ptr ptr vm:cons-cdr-slot vm:list-pointer-type)
  50.       (inst add count count (fixnum 1))
  51.       (test-type ptr temp loop nil vm:list-pointer-type)
  52.  
  53.       (cerror-call vop done object-not-list-error ptr)
  54.  
  55.       (emit-label done)
  56.       (move result count))))
  57.        
  58.  
  59. (define-static-function length (object) :translate length)
  60.  
  61.